﻿using Resto.CostControl.Core.Facade.DishModule.FacadeObject;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Resto.CostControl.Core.Facade.DishModule.DataTransferObject;
using System.Collections.Generic;
using Enterprise.Framework.Core.Container;

namespace Resto.CostControl.UnitTest.DishModule
{
    
    
    /// <summary>
    ///这是 DishFOTest 的测试类，旨在
    ///包含所有 DishFOTest 单元测试
    ///</summary>
    [TestClass()]
    public class DishFOTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试特性
        // 
        //编写测试时，还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///AddDish 的测试
        ///</summary>
        [TestMethod()]
        public void AddDishTest()
        {
            DishFO target = ObjectCreator.Create<DishFO>();
            DishDTO dishDTO = new DishDTO()
            {
                Category = "a",
                Code = "11",
                CookType = "b",
                Cost = 11m,
                Name = "c1",
                Price = 2m,
            };


            DishMaterialDTO item1 = new DishMaterialDTO(1);
            DishMaterialDTO item2 = new DishMaterialDTO(2);

            List<DishMaterialDTO> list = new List<DishMaterialDTO>();
            list.Add(item1);
            list.Add(item2);

            target.AddDish(dishDTO, list);
            
        }

        [TestMethod]
        public void UpdateDishTest()
        {
            DishFO target = ObjectCreator.Create<DishFO>();
            DishDTO dishDTO = new DishDTO()
            {
                Category = "yy",
                Code = "9993",
                CookType = "b",
                Cost = 11m,
                Name = "9993",
                Price = 2m,
            };


            DishMaterialDTO item1 = new DishMaterialDTO(1);
            DishMaterialDTO item2 = new DishMaterialDTO(2);
            DishMaterialDTO item3 = new DishMaterialDTO(3);

            List<DishMaterialDTO> list = new List<DishMaterialDTO>();
            list.Add(item1);
            list.Add(item2);

            target.AddDish(dishDTO, list);

            list.Clear();
            list.Add(item3);

            target.UpdateDish(dishDTO, list);
            
        }
    }
}
